package com.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class SimpleDBSource implements DBSource{
	
	public Connection getConn(){
		Connection conn = null;
		String user = "root";
		String password = "root";
		String url = "jdbc:mysql://localhost:3306/ajax?useUnicode=true&characterEncoding=GB2312";
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection(url, user, password);
		} catch (Exception e) {
			
			e.printStackTrace();
		}
		return conn;
	}
	
	public void closeConn(Connection conn){
		
			try {
				if(conn!=null&&!conn.isClosed()){
					conn.close();
				}
			} catch (SQLException e) {
				
				e.printStackTrace();
			}		
	}
}
